package com.freeheart.validation;


import com.freeheart.validation.constraintvalidators.in.InCollection;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

/**
 * @author: EmperorHeart
 * @date: 2025/5/10 1:08
 * @description
 */
@Component
@EnableScheduling
public class TempInCollection implements InCollection, InitializingBean {

    public static final Set<String> TRADE_TYPE_SET = new HashSet<>();


    @Override
    public Collection<?> getCollection() {
        return TRADE_TYPE_SET;
    }


    // 定时更新这个集合
    @Scheduled(cron = "0 */5 * * * *")
    public void refresh(){
        this.updateSet();
    }


    // 初始化就刷新一次
    @Override
    public void afterPropertiesSet() throws Exception {
        this.updateSet();
    }


    public void updateSet(){
        // 查库
    }
}
